<header class="bar-header">
  <ul>
    <li><a class="site-title" href="{{ site.url }}{{ site.baseurl }}" title="小神仙的博客">
      <span style="font-weight:800">小神仙</span>
    </a></li>
    {% for link in site.links-light %}
      <li><a class="navigation" href="{{ site.url }}{{ site.baseurl }}{{ link.url }}" title="{{ link.title }}">
        <svg class="icon-menu mobile-only"><use xlink:href="#icon-{{ link.icon }}"></use></svg>
        <span class="desktop-only">{{ link.title }}</span>
      </a></li>
    {% endfor %}

    <!-- 切换主题 -->
    <li><a id="theme" class="navigation" title="切换黑白主题 (beta)" style="cursor:pointer" onclick="(function(){
      document.body.classList.toggle('light-theme');
      document.body.classList.toggle('dark-theme');
      if (document.body.classList.contains('dark-theme')) { document.cookie = 'theme=dark'; }
      else { document.cookie = 'theme=light'; }
    })()">
      <svg class="icon-menu mobile-only"><use xlink:href="#icon-theme"></use></svg>
      <span class="desktop-only">主题</span>
    </a></li>
    <script type="text/javascript">
      function getCookie(cname) {
        var name = cname + "=";
        var decodedCookie = decodeURIComponent(document.cookie);
        var ca = decodedCookie.split(';');
        for(var i = 0; i <ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') {
            c = c.substring(1);
          }
          if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
          }
        }
        return "";
      }
      var theme = getCookie("theme");
      console.log(theme);
      if (theme == 'light') document.body.classList.remove('dark-theme');
      else if (theme == 'dark') document.body.classList.add('dark-theme');
    </script>
    <!-- end 切换主题 -->
  </ul>

  <a id="search" class="dosearch">
    <div class="search-box search-desktop-only">
      <span>搜索</span>
      <svg class="icon-search"><use xlink:href="#icon-search"></use></svg>
    </div>
    <svg class="icon-search search-mobile-only"><use xlink:href="#icon-search"></use></svg>
  </a>
</header>

{% include menu.html %}
{% include search.html %}
